/* 
 * File:   GameControl.h
 * Copyright (C) 2008, 2009
 *		Sergio Padrino Recio (PadrinatoR)
 *
 * Created on 18 de octubre de 2008, 18:32
 *
 * This file is part of BombProject.
 * 
 * BombProject is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
   
 * BombProject is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with BombProject.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _GAMECONTROL_H
#define	_GAMECONTROL_H

#include "InputHandler.h"
#include <string>

#define MAX_CONTROLS	8

enum ButtonID {
	BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
	BUTTON_FIRE, BUTTON_SPECIAL1, BUTTON_SPECIAL2,
	NUM_BUTTONS
};

class GameControl {

//----------------- STATIC STUFF -----------------
private:
	static GameControl mControls[MAX_CONTROLS];
	static ButtonState mGlobalButtonState[NUM_BUTTONS];

public:
	static void initGameControls();

	static void loadGameControls(string filename);
	static void saveGameControls(string filename);

	static GameControl* getGameControl(Uint8 index);
	static ButtonState* getGlobalButtonState(ButtonID id);
	static void updateGlobalButtonState();
	static void clearAll();

//--------------- NON-STATIC STUFF ---------------
private:
	ButtonState* mButtonState[NUM_BUTTONS]; //mButtonUp, *mButtonDown, *mButtonLeft, *mButtonRight, *mButtonFire, *mButtonSpecial1, *mButtonSpecial2;
	DeviceButtonInfo mButtonInfo[NUM_BUTTONS]; //, mInfoButtonDown, mInfoButtonLeft, mInfoButtonRight, mInfoButtonFire, mInfoButtonSpecial1, mInfoButtonSpecial2;

public:
	GameControl();
	~GameControl();

	ButtonState* getButtonState(ButtonID id);
	DeviceButtonInfo getButtonInfo(ButtonID id);
	void setButtonInfo(ButtonID id, DeviceButtonInfo& info);
	void clear();
};

#endif	/* _GAMECONTROL_H */

